package utils

import "golang.org/x/crypto/bcrypt"

func HashPassword(password string) (string, error) {

	hashPwd, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
	if err != nil {
		return "", err
	}
	return string(hashPwd), nil
}

func CheckPassword(hashpwd, inputPassword string) error {
	err := bcrypt.CompareHashAndPassword([]byte(hashpwd), []byte(inputPassword))
	return err
}
